#pragma once
#include <widgets/Defines.h>

#include <QImage>
#include <QMap>
#include <QVector>

#include "core.h"

class S_CORE_EXPORT SImage {
 public:
  SImage(const QString& path);
  ~SImage();

  void setDevicePixelRatio(float f);
  float devicePixelRatio() const;
  QSize size() const;
  QRect rect() const;
  QImage* img() const { return m_img; }
  QString imgPath() const { return m_imgPath; }

  operator QImage();
  float width() const;
  float height() const;

 private:
  QImage* m_img = nullptr;
  QString m_imgPath;
};
class S_CORE_EXPORT ImgMgr {
 public:
  static ImgMgr& instance();
  void clean();

  void registerImgs(QString module);
  SImage* image(QString imgId, WidgetStatus type = WidgetStatus::kNormal,
                float scale = -1);
  QString imagePath(QString imgId, WidgetStatus type = WidgetStatus::kNormal,
                    float scale = -1);

 private:
  ImgMgr() = default;

 private:
  QMap<QString, QVector<SImage*> > m_imgs;  // load when used?
};
